package collection.list;

import collection.Printer;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * 1.基于动态数组，理论上插入慢、读取快
 * 2.线程不安全
 */
public class ArrayListTest {

    @Test
    public void testAdd() {

        List<String> list = new ArrayList<String>();
        Long startTime = System.currentTimeMillis();
        for (int i = 0; i < Printer.COUNT; i++) {
            list.add("test" + i);
        }
        Long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);

    }

    @Test
    public void test() {

        List<String> list = new ArrayList<String>();
        list.add("test");
        list.get(0);
    }

}
